# from app.user.model import User as UserTable
# import jwt
# from config import Config
# import datetime
# from common import errors
# from exts import db
#
#
# class User:
#     id = None
#     user_table = None
#
#     def set_user_id(self, user_id):
#         self.id = user_id
#
#     def get_user_table(self):
#         self.user_table = UserTable.query.filter_by(id=self.id).first()
#
#     # def login(self, username, password):
#     #     user_table = UserTable.query.filter_by(username=username).first()
#     #     if user_table.check_password(password):
#     #         self.id = user_table.id
#     #         token = self.generate_token()
#     #         return token.decode('utf-8'), user_table
#     #     else:
#     #         raise errors.NotMatchOrUserDoesNotExistError
#
#     def generate_token(self):
#         payload = {
#             'exp': datetime.datetime.utcnow() + datetime.timedelta(days=10, seconds=5),
#             'iat': datetime.datetime.utcnow(),
#             'sub': self.id
#         }
#         return jwt.encode(payload, Config.SECRET_KEY, algorithm='HS256')
#
#     def logout(self, token):
#         pass
#
#     def reset_password(self, new_password):
#         self.user_table.password = new_password
#         db.session.commit()
#         # self.user_table.update()
#
#
#
